package util

import (
	"JoRedis/lib/logger"
	"encoding/json"
)

// SlcToStr 字符串切片转json数组字符串["a","b","c"]
func SlcToStr(slc []string) (string, error) {
	bytes, err := json.Marshal(slc)
	if err != nil {
		logger.Error("slcToStr转换失败!")
		return "", err
	}
	return string(bytes), nil
}

// StrToBytesSlc 多个字符串转二维字节
func StrToBytesSlc(args ...string) [][]byte {
	bytesSlc := make([][]byte, len(args))
	for i, arg := range args {
		bytesSlc[i] = []byte(arg)
	}
	return bytesSlc
}
